<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>管理收货地址</title>
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, width=device-width">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-touch-fullscreen" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<meta name="format-detection" content="address=no">
		<link rel="stylesheet" type="text/css" href="css/common.css">
		<link rel="stylesheet" type="text/css" href="css/index.css">
		<link rel="stylesheet" type="text/css" href="css/mui.min.css"/>
		<link rel="stylesheet" href="css/reset.css">
		<script src="js/jquery-1.8.2.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="js/iscroll.js"></script>
		<script type="text/javascript" src="js/jquery.flexslider-min.js"></script>
		<script src="js/hmt.js" type="text/javascript"></script>
		<script type="text/javascript" src="js/index.js"></script>
		<script src="js/swiper.min.js" type="text/javascript" ></script>
		
		<script type="text/javascript" src="http://yanyubao.tseo.cn/Tpl/static/jquery.tmpl.js"></script>
		<script type="text/javascript" src="js/abot.js"></script>
		<script type="text/javascript" src="http://yanyubao.tseo.cn/api/shopapp.js"></script>
		<script type="text/javascript" src="js/abot.function.js"></script>
	</head>
	<body>
		<header class="hasManyCity hasManyCitytwo" id="header">
			<a href="javascript:history.go(-1)" class="fl fanhui">
			<i class="iconfont">&#xe6d4;</i></a>
			<div class="header-tit">
				管理收货地址
			</div>
		</header>
		<div id="container">
		    <div id="main" class="mui-clearfix contaniner">
		    
		<script id="address_list" type="text/x-jquery-tmpl">
		    	<div class="addlist clearfloat">
		    		<div class="top clearfloat box-s">
		    			<ul>
		    				<li>
		    					<span class="fl">${name}</span>
		    					<span class="fr">${mobile}</span>
		    				</li>
		    				<li>
		    					${province_name}省${city_name}市${district_name}${address}
		    				</li>
		    			</ul>
		    		</div>
		    		<div class="bottom clearfloat box-s">
		    			<section class="shopcar clearfloat">
		    				<div class="list listtwo clearfloat">
								<div class="xuan xuantwo clearfloat fl">
				    				<div class="radio" > 
									    <label>
									        <input type="checkbox" name="sex" value="" />
									        <div class="option" onclick="moren(${addressid})"></div>
									    </label>
									</div>
				    			</div>
			    			
							<span class="mradd fl">默认地址</span>
							<div class="right fr clearfloat">
								<a href="#" class="fr" onclick="del_address(${addressid})">
									<i class="iconfont icon-lajixiang icon-shanchutwo"></i>
									删除
								</a>
								<a href="#" class="fr" onclick="address_update(${addressid})">
									<i class="iconfont icon-bianji bianjittt"></i>
									编辑
								</a>							
							</div>
							</div>
						</section>
		    		</div>
		    	</div>
		    	</script>
		    </div>
		    <a href="add-address.html" class="address-add fl">
	     		添加新地址
	     	</a>
	    </div>
	    
	</body>	
	<script type="text/javascript">
	
	function get_address_del_callback(res){
		
		 console.log(res);
		
		if(res.code == 1){
			
			alert(res.msg);
			
			window.location.reload()
			
		}else{ 
			
			alert(res.msg);
		 }	
	
	}
	function get_moren_callback(res){
		alert(res.msg)
		window.location.href = "indiana-shu.html";
	}
	function moren(addressid){
		var loginItem = get_login_info();//获取登录信息 
		
		var userid = get_login_info().userid;
		
		var checkstr = get_login_info().checkstr;
		
		var moren_function_name = "address_save";
		
		var moren_data = {'userid':userid, 'checkstr':checkstr, 'action':'edit','moren':1,'addressid':addressid};
		
		ajax_request_server(moren_function_name, moren_data, get_moren_callback);
	}
	
	function del_address(addressid){
		
		var function_address_name = "address_save";
		
		var loginItem = get_login_info();//获取登录信息 
		
		var userid = get_login_info().userid;
		
		var checkstr = get_login_info().checkstr;
		
		var action = "del";
		
		var request_address_data = {'userid':userid, 'checkstr':checkstr, 'action':action,'addressid':addressid};
		
		ajax_request_server(function_address_name, request_address_data, get_address_del_callback);
		
	}
	
	function address_update(addressid){
		
		var function_address_name = "address_save";
		
		var loginItem = get_login_info();//获取登录信息 
		
		var userid = get_login_info().userid;
		
		var checkstr = get_login_info().checkstr;
		
		var action = "del";
		
		var request_address_data = {'userid':userid, 'checkstr':checkstr, 'action':action,'addressid':addressid};
		
	}
	
	function get_address_list_callback(res){
		
		console.log(res)
		
		 $("#address_list").tmpl(res.addressList).appendTo("#main");
		
	}
		$(function(){
			
			var function_name = "address_list";
			
			var loginItem = get_login_info();//获取登录信息 
			
			var userid = loginItem.userid;
			
			var checkstr = loginItem.checkstr;
			
			var request_data = {'userid':userid, 'checkstr':checkstr};
			
				ajax_request_server(function_name, request_data, get_address_list_callback);
			
		});
	
	</script>
		
</html>
